package com.trailwalker.traceability.net;

import com.trailwalker.JavaUtils.log.LogUtils;
import com.trailwalker.traceability.entitiy.application.GlobalData;
import com.trailwalker.traceability.net.interceptor.CompanyInterceptor;
import okhttp3.Interceptor;
import retrofit2.Retrofit;

import java.util.ArrayList;
import java.util.List;

public class CompanyNetworkManager extends Network {

    private static final String TAG = CompanyNetworkManager.class.getSimpleName();

    /**
     * debug mode
     */
    //public static final String IP = "192.168.31.90:8080";

    /**
     * debug mode Trailwalker
     */
    //public static final String IP="192.168.31.202:8888";

    /**
     * release mode
     */
    public static final String IP = "www.dsionsoft.com/protrace";

    /**
     * special mode
     */
    //public static final String IP = "192.168.10.16";

    private static List<Interceptor> interceptorList = new ArrayList<>();

    public static Retrofit getApiInstance(GlobalData globalData) {
        if (interceptorList.size() == 0) {
            interceptorList.add(CompanyInterceptor.create(globalData));
        }
        String ip = globalData.getString("ip", IP);
        LogUtils.log(TAG, "ip >> " + ip);
        String baseUrl = "http://" + ip + "/";
        return getRetrofitInstance(baseUrl, interceptorList);
    }

}
